package elements.axis ;
import string.Utils;
import ColorConverter.Color;
import ColorConverter;
	
class XLabelStyle
{
	public var size: Float;// = 10;
	public var color: Float;// = 0x000000;
	public var vertical:Bool;// = false;
	public var diag:Bool;// = false;
	public var step: Float;// = 1;
	public var show_labels:Bool;

	public function new( json:Dynamic )
	{
		size = 10;
		color = 0x000000;
		vertical = false;
		diag = false;
		step = 1;

		if( json != null )
			return;
			
		if( !Reflect.hasField(json,"x_label_style") )
			return;
		
		if( Reflect.hasField(json.x_label_style,"visible") || json.x_label_style.visible )
		{
			this.show_labels = true;
			
			var x_label_style : Dynamic = json.x_label_style;
			
			if( Reflect.hasField(x_label_style,"size") )
				this.size = x_label_style.size;
				
			if( Reflect.hasField(x_label_style,"color") )
				this.color = ColorConverter.toFloat(Hex(x_label_style.color));

			if( Reflect.hasField(x_label_style,"rotation") )
			{
				this.vertical = (x_label_style.rotation==1);
				this.diag = (x_label_style.rotation==2);
			}
			
			if( Reflect.hasField(x_label_style,"step") )
				this.step = x_label_style.step;
		}
		else
			this.show_labels = true;
	}
}
